package com.utils;

import com.config.DBConfig;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBUtils {
    static {
        try {
            Class.forName(DBConfig.getInstance().getDriverClass());
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    public static Connection getConnection() throws SQLException {
        return DriverManager.getConnection(
                DBConfig.getInstance().getJdbcUrl(),
                DBConfig.getInstance().getUsername(),
                DBConfig.getInstance().getPassword()
        );
    }
}
